package shopping;

import java.util.Arrays;
public class CartitemList {
	User user;
	

	int num;
	Goods goods;
	double OneSortPrice;
	double Allsum;
	

	
public CartitemList(){
	
}
	public CartitemList(Goods goods,int num,User user) {
		this.goods = goods;
		this.num = num;
		this.OneSortPrice=goods.getPrice()*num;
		CartitemList[] temp = Arrays.copyOf(user.shoppingcart2.cartitem,user.shoppingcart2.cartitem.length);
		user.shoppingcart2.cartitem = new CartitemList[user.shoppingcart2.cartitem.length+1];
		user.shoppingcart2.cartitem = Arrays.copyOf(temp,temp.length);
		user.shoppingcart2.cartitem[temp.length] = this;
		//user.cartitem.add(this);

		this.Allsum = user.shoppingcart.getAllSum();
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	/*public double getAllSum(){

		double sum=0;

		for(int i=0;i<cartitem.size();i++){

			sum +=cartitem.get(i).OneSortPrice; 

		}

		return sum;

	}*/


}
